/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package grupb.upf.XMLObjects.impl;

import java.io.Serializable;
import java.util.Hashtable;
import java.util.Map;

/**
 * <p>This class implements the management of the predefined tags.</p>
 *
 * @version    0.0.1-SNAPSHOT
 * @author     Group B
 */
public final class PredefinedTag implements grupb.upf.XMLObjects.Tag,
        Serializable {
    /**
     * The serialVersionUID is created to be able to serialize this class, it's
     * necessary because it will be sent.
     */
    private static final long serialVersionUID = 1L;
    /**
     * The predefined tag.
     */
    private String predefinedTag;
    /**
     * The category of the tag.
     */
    private String category;
    /**
     * The coordinates of the predefined tags.
     */
    private Map < String, Integer > coordenates = null;
    /**
     * This method allows as to set a predefined tag.
     * @param tag The predefined tag.
     */
    @Override
    public void setTag(final String tag) {
        this.predefinedTag = tag;
    }
    /**
     * This method returns the predefined tag.
     * @return The predefined tag
     */
    @Override
    public String getTag() {
        return this.predefinedTag;
    }
    /**
     * This method allows us to set the coordinates of a predefined tag.
     * @param x1 As is a square we need four coordinates
     * @param x2 As is a square we need four coordinates
     * @param y1 As is a square we need four coordinates
     * @param y2 As is a square we need four coordinates
     */
    @Override
    public void setCoordenates(final int x1, final int x2,
            final int y1, final int y2) {
        this.coordenates = new Hashtable < String, Integer > ();
        this.coordenates.put("x1", x1);
        this.coordenates.put("x2", x2);
        this.coordenates.put("y1", y1);
        this.coordenates.put("y2", y2);
    }
    /**
     * This method returns the coordinates.
     * @return The coordinates
     */
    @Override
    public Map getCoordenates() {
        return this.coordenates;
    }
    /**
     * This method clear the coordinates.
     */
    @Override
    public void clearCoordenates() {
        this.coordenates = null;
    }
    /**
     * This method allows us to set a category.
     * @param addCategory The category of the tag
     */
    public void setCategory(final String addCategory) {
        this.category = addCategory;
    }
    /**
     * This method returns the category of a tag.
     * @return The category of the tag
     */
    public String getCategory() {
        return this.category;
    }
    /**
     * This method allows us to clear the data.
     */
    @Override
    public void clear() {
        this.predefinedTag = "";
        if (this.coordenates != null) {
            this.coordenates.clear();
        }
    }
}
